// pages/home/shop/shop.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopid:"",
    show: false,
    toter: 0,
    shoping: [],
    good: "",
    goods: [{
        goodsid: 1,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 2,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 3,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 4,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 5,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 6,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16"
      },
      {
        goodsid: 7,
        url: "https://img.yzcdn.cn/vant/cat.jpeg",
        name: "蛋炒饭",
        material: "蛋，饭",
        price: "16",

      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
wx.request({
  url: '',
  method:"POST",
  header:{
    "cookie":wx.getStorageSync('sessionid'),
    "token":wx.getStorageSync('session'),
  }, 
 data:{
   shopid:options.shopid,
 },
 success (res) {
  console.log(res)
  that.data.goods=res.data.goods
}
})
 
  },
  addto(e) {
    // let i = e.currentTarget.id
    // console.log(i)
    // let that = this
    // let good = that.data.goods
    wx.navigateTo({
      url: '/pages/home/shop/shop?shopid='+[e.currentTarget.id],
    })
 
  },
  showPopup() {
    // console.log(666)
    this.setData({
      show: true
    });
  },

  onClose() {
    this.setData({
      show: false
    });
  },
  newshop(){
    wx.navigateTo({
      url: '/pages/home/newshop/newshop',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    let that = this
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];
    prevPage.setData({
      shoptotal:that.data.toter,
      shoping: that.data.shoping//参数
    })
    wx.setStorage({
      data: that.data.shoping,
      key: that.data.shopid,
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */

  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})